package com.lighting.common.feign.search.vo;


import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
public class SearchPage<T> {
    /**
     * 当前页
     */
    private int page;
    /**
     * 每页数量
     */
    private int size;
    /**
     * 滚动分页ID(当scrollId不为null时，page无效)
     */
    private String scrollId;
    /**
     * 总记录数
     */
    private long total;
    /**
     * 共几页
     */
    private long pageSize;
    /**
     * 数据集
     */
    private List<T> content;

    public SearchPage() {
        super();
    }

    public SearchPage(int page, int size, long total, List<T> content) {
        this.page = page;
        this.size = size;
        this.total = total;
        this.content = content;
        if (total > 0) {
            this.pageSize = total / size + total % size > 0 ? 1 : 0;
        }
    }

    public SearchPage(int page, int size, long total, String scrollId, List<T> content) {
        this(page, size, total, content);
        this.scrollId = scrollId;
    }
}
